package org.jeecg.modules.online.desform.test;

import org.hibernate.dialect.MySQL5Dialect;
import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.type.StandardBasicTypes;
import org.jeecg.TristoneSystemApplication;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @description:
 * @author: dw
 * @time: 2021/7/15 16:00
 */

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = TristoneSystemApplication.class)
public class MyMySQLDialect extends MySQL5Dialect {

    /**
     * 添加 (Mysql)内置函数和自定义函数
     * 在此类中添加
     */
    public MyMySQLDialect() {


        registerFunction( "ascii", new StandardSQLFunction( "ascii", StandardBasicTypes.INTEGER ) );
        registerFunction( "bin", new StandardSQLFunction( "bin", StandardBasicTypes.STRING ) );
    }

    /**
     * 解决启动时数字溢出的错误
     */

    public String getQuerySequencesString() {
        return "select * from user_sequences";
    }
}
